package com.zx.zxblog.controller;

import com.zx.zxblog.entity.enums.SysConfigEnum;
import com.zx.zxblog.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class AboutController {

    @Autowired
    SysConfigService sysConfigService;

    @GetMapping("/about")
    public String about(Model model){

        // 获取简介
        String intro = sysConfigService.getByEnums(SysConfigEnum.ABOUT_ME_INTRODUCTION).getValue();
        // 获取内容
        String content = sysConfigService.getByEnums(SysConfigEnum.ABOUT_ME_CONTENT).getValue();
        // 获取标签11
        String tagStr = sysConfigService.getByEnums(SysConfigEnum.ABOUT_ME_TAG).getValue();
        // 获取作者
        String author = sysConfigService.getByEnums(SysConfigEnum.AUTHOR).getValue();

        //逗号分割
        String[] tags = tagStr.split("[,，]");

        model.addAttribute("intro",intro);
        model.addAttribute("content",content);
        model.addAttribute("tags",tags);
        model.addAttribute("author",author);


        return "about";
    }

}
